"use strict";
const fse = require("fs-extra");
(function initLogger() {
	//启用取代console.log的配置，这样console的输出就全部到控制台
	fse.ensureDirSync("logs");
	console.log("控制台输入将重定向到日志");
	const log4js = require("log4js");
	log4js.configure(require("./config/log4js"));

	const debugLogger = log4js.getLogger("debug");
	debugLogger.setLevel("debug");
	const originalLog = console.log.bind(console);
	console.log = function() {
		originalLog(...arguments);
		debugLogger.debug(...arguments);
	};

	const errorLogger = log4js.getLogger("error");
	errorLogger.setLevel("warn");
	const originalError = console.error.bind(console);
	const originalWarn = console.warn.bind(console);
	console.error = function() {
		originalError(...arguments);
		debugLogger.debug(...arguments);
		errorLogger.error(...arguments);
	};
	console.warn = function() {
		originalWarn(...arguments);
		debugLogger.debug(...arguments);
		errorLogger.warn(...arguments);
	};
})();
module.exports = null;